import { createStore, createLogger } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'
import cart from './modules/cart'
import user from './modules/user'
import category from './modules/category'
export default createStore({
  // vuex的数据
  state: {
  },
  // vuex的计算属性
  getters: {
    token: state => state.user.profile.token
  },
  // 改变state的唯一路径 commit
  mutations: {
  },
  // 可以有异步操作,异步提交多个mutations
  actions: {
  },
  // 模块化管理vuex
  modules: {
    cart,
    user,
    category
  },
  plugins: [
    createPersistedstate({
      key: 'erabbit-client-pc-store',
      paths: ['user', 'cart']
    }),
    createLogger()
  ]
})
